﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace form1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnketqua_Click(object sender, EventArgs e)
        {
            double danta;
            double  b = int.Parse(txtb.Text);
            double a = int.Parse(txta.Text);
            double c= int.Parse(txtc.Text);
            double x1, x2;

            danta = b * b - 4 * a * c;

            if (danta > 0)
            {
                x1 = (-b + Math.Sqrt(danta)) / 2 * a;
                x2 = (-b -  Math.Sqrt(danta)) / 2 * a;
            }
            else
            {
                if (danta == 0)
                {
                    x1 = b / 2 * a;
                    x2 = -b / 2 * a;
                }
                else
                {
                    x1 = 0;
                    x2 = 0;
                    MessageBox.Show("phuong trinh vo nghiem");
                }
            }
            txtx1.Text = x1.ToString();
            txtx2.Text = x2.ToString();

        }
    }
}
